#include <queue>
#include <thread>
#include <chrono>
#include <iostream>

std::queue<int> buffer;

void productor_main_loop(){
    for(int i = 0; i < 100; i++){
        static int counter = 0;
        buffer.push(counter++);
        std::this_thread::sleep_for(std::chrono::milliseconds(50));
    }
}

void consumer_main_loop(){
    for(int i = 0; i < 100; i++){
        if(!buffer.empty()){
            int value = buffer.front();
            buffer.pop();
            std::cout << "get value :: " << value << std::endl;
            std::this_thread::sleep_for(std::chrono::milliseconds(70));
        }
    }
}

int main(){
    std::thread thread_productor(productor_main_loop);
    std::thread thread_consumer(consumer_main_loop);

    thread_productor.join();
    thread_consumer.join();
}
